package com.itheima.objectStream;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.util.ArrayList;

public class ObjectOutputStreamDemo01 {
    public static void main(String[] args) throws IOException {
        Student stu = new Student("001","张三",20);
        Student stu1 = new Student("002","李四",22);
        Student stu2 = new Student("003","王五",24);
        ArrayList<Student> arrayList = new ArrayList<>();
        arrayList.add(stu);
        arrayList.add(stu1);

        //创建对象序列化流
        ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("a.txt"));

        oos.writeObject(arrayList);
        oos.writeObject(stu);
        oos.writeObject(stu1);
        oos.writeObject(stu2);
        oos.close();
    }
}
